package com.android.juvid.testnet;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.content.Intent;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.RelativeLayout;
import android.widget.LinearLayout;
import android.support.v7.app.ActionBar.LayoutParams;

import android.view.LayoutInflater;

public class MainActivity extends AppCompatActivity implements OnRepay {
    private application app;
    XiaoMing XiaoMing;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);





        app = (application) getApplication(); // 获得CustomApplication对象
        app.setValue("Jutewei"); // 重新设置值
        Log.i("FirstActivity", "初始值=====" + app.getValue()); // 获取进程中的全局变量值，看是否是初始化值

        XiaoMing = new XiaoMing();
        XiaoMing.XiaoHong=this;
        XiaoMing.testString="jutewei";
        Log.e("初始化", XiaoMing.testString);
        Button nextbtn=(Button) findViewById(R.id.nextvcIn);
        nextbtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Test(2,"这是个简单的LOG");
            }
        });
/**自动回调相对于OC block*/
        XiaoMing.autoHuanQian( new OnRepay() {
            @Override
            public void onRepay() {
                Log.e("小朱", "正确回调");
            }

            @Override
            public void onError() {
                Log.e("小朱", "错误回调");
            }
        } );


        XiaoMing.JieQian();


    }
    /**自动回调相对于OC代理*/
    public void onRepay() {// 小明还钱的时候,小红接收, 返回true:收到了钱, 返回false:没收收到
        Log.e("小红", "正确回调,收到钱");

    }
    public void onError() {// 小明还钱的时候,小红接收, 返回true:收到了钱, 返回false:没收收到
        Log.e("小红", "错误回调,没收到钱");
    }
    public void Test(int d,String value){
        Intent intent = new Intent();
        intent.setClass(this, MyListView2.class);
        this.startActivity(intent);
        Log.v("test",value);

    }

}
